home *** CD-ROM | disk | FTP | other *** search
- global gWorld, gSolidFormat, gTransFormat, gTargetPoints, gPowerupList
-
- on newGenerateMesh whichTrack
- theTrack = getTrack(whichTrack)
- NumSegs = theTrack.road.count
- DistPerSection = 500.0
- FacesPerSeg = 16
- VerticesPerSeg = 8
- havokFacesPerSeg = 6
- havokVerticesPerSeg = 4
- the randomSeed = 1001
- theTex = gWorld.newTexture("RoadTexture", #fromCastMember, member("Track", "Graphics"))
- roadShader = gWorld.newShader("RoadShader", #standard)
- roadShader.texture = theTex
- roadShader.ambient = rgb(200, 200, 200)
- roadShader.diffuse = rgb(255, 255, 255)
- roadShader.specular = rgb(0, 0, 0)
- roadShader.shininess = 0
- roadShader.useDiffuseWithTexture = 0
- roadShader.textureTransformList[1].scale = vector(1, 1, 1)
- theTex = gWorld.newTexture("RoadTexture2", #fromCastMember, member("Track2", "Graphics"))
- roadShader2 = gWorld.newShader("RoadShader2", #standard)
- roadShader2.texture = theTex
- roadShader2.ambient = rgb(200, 200, 200)
- roadShader2.diffuse = rgb(255, 255, 255)
- roadShader2.specular = rgb(0, 0, 0)
- roadShader2.shininess = 0
- roadShader2.useDiffuseWithTexture = 0
- roadShader2.textureTransformList[1].scale = vector(1, 1, 1)
- roadShaders = [roadShader, roadShader2]
- theTex = gWorld.newTexture("RoadBottomTexture", #fromCastMember, member("trackbottom", "Graphics"))
- roadBotShader = gWorld.newShader("RoadBotShader", #standard)
- roadBotShader.texture = theTex
- roadBotShader.ambient = rgb(200, 200, 200)
- roadBotShader.diffuse = rgb(255, 255, 255)
- roadBotShader.specular = rgb(0, 0, 0)
- roadBotShader.shininess = 0
- roadBotShader.useDiffuseWithTexture = 0
- roadBotShader.textureTransformList[1].scale = vector(1, 0.5, 1)
- theTex = gWorld.newTexture("WallSideTexture", #fromCastMember, member("trackside", "Graphics"))
- wallSideShader = gWorld.newShader("WallSideTexture", #standard)
- wallSideShader.texture = theTex
- wallSideShader.ambient = rgb(200, 200, 200)
- wallSideShader.diffuse = rgb(255, 255, 255)
- wallSideShader.specular = rgb(0, 0, 0)
- wallSideShader.shininess = 0
- wallSideShader.useDiffuseWithTexture = 0
- wallSideShader.textureTransformList[1].scale = vector(1, 0.5, 1)
- theTex = gWorld.newTexture("WallTopTexture", #fromCastMember, member("tracktop", "Graphics"))
- wallTopShader = gWorld.newShader("WallTopTexture", #standard)
- wallTopShader.texture = theTex
- wallTopShader.ambient = rgb(200, 200, 200)
- wallTopShader.diffuse = rgb(255, 255, 255)
- wallTopShader.specular = rgb(0, 0, 0)
- wallTopShader.shininess = 0
- wallTopShader.useDiffuseWithTexture = 0
- wallTopShader.textureTransformList[1].scale = vector(1, 0.5, 1)
- theTex = gWorld.newTexture("FinishLineTexture", #fromCastMember, member("Trackfinish", "Graphics"))
- finishShader = gWorld.newShader("FinishLineShader", #standard)
- finishShader.texture = theTex
- finishShader.ambient = rgb(200, 200, 200)
- finishShader.diffuse = rgb(255, 255, 255)
- finishShader.specular = rgb(0, 0, 0)
- finishShader.shininess = 0
- finishShader.useDiffuseWithTexture = 0
- finishShader.textureTransformList[1].scale = vector(1, 1, 1)
- theTex = gWorld.newTexture("EndTexture", #fromCastMember, member("EndTexture"))
- theTex.renderFormat = gSolidFormat
- logoList = []
- billboardList = []
- theNamesList = ["bags", "getthetaste", "3dsfuncom", "swirlblue", "swirlorange"]
- repeat with texName in theNamesList
- theTex = gWorld.newTexture(texName & "Banner", #fromCastMember, member(texName))
- theTex.renderFormat = gSolidFormat
- theShader1 = gWorld.newShader(texName & "Shader", #standard)
- theShader1.texture = theTex
- theShader1.ambient = rgb(255, 255, 255)
- theShader1.diffuse = rgb(255, 255, 255)
- theShader1.emissive = rgb(255, 255, 255)
- theShader1.shininess = 0
- theShader1.textureTransformList[1].scale = vector(0.25, 1, 0.5)
- theShader = gWorld.newShader(texName & "BillboardShader", #standard)
- theShader.texture = theTex
- theShader.ambient = rgb(255, 255, 255)
- theShader.diffuse = rgb(255, 255, 255)
- theShader1.emissive = rgb(255, 255, 255)
- theShader.shininess = 0
- theShader.textureTransformList[1].scale = vector(1, 1, 1)
- if (texName = "bags") or (texName = "getthetaste") or (texName = "3dsfuncom") then
- add(logoList, theShader1)
- add(logoList, theShader1)
- add(logoList, theShader1)
- add(logoList, theShader1)
- add(billboardList, theShader)
- end if
- end repeat
- put billboardList
- startShader = gWorld.newShader("StartShader", #standard)
- startShader.texture = gWorld.texture("bagsBanner")
- startShader.ambient = rgb(255, 255, 255)
- startShader.diffuse = rgb(255, 255, 255)
- startShader.shininess = 0
- startShader.textureTransformList[1].scale = vector(1, 1, 1)
- theTex = gWorld.newTexture("speedBoost", #fromCastMember, member("speedboost"))
- theTex.renderFormat = gTransFormat
- powerupShader = gWorld.newShader("SpeedBoostShader", #standard)
- powerupShader.texture = theTex
- powerupShader.ambient = rgb(255, 255, 255)
- powerupShader.diffuse = rgb(255, 255, 255)
- powerupShader.useDiffuseWithTexture = 0
- powerupShader.shininess = 0
- buildingModel = gWorld.cloneModelFromCastmember("Building1", "Building01", member("Building01"))
- buildingModel.shader.textureTransformList[1].scale = vector(0.40000000000000002, 0.10000000000000001, 1)
- buildingModel.shader.texture = gWorld.texture("BuildingTex_2")
- buildingModel.removeFromWorld()
- buildingResource = buildingModel.resource
- buildingModel2 = buildingModel.clone("Building2")
- buildingModel2.shader = gWorld.newShader("BuildingShader2", #standard)
- buildingModel2.shader.texture = gWorld.texture("BuildingTex_1")
- buildingModel2.shader.textureTransformList[1].scale = vector(0.40000000000000002, 0.10000000000000001, 1)
- buildingModel2.shader.shininess = 0
- buildingModel2.shader.ambient = buildingModel.shader.ambient
- buildingModel2.shader.diffuse = buildingModel.shader.diffuse
- trackGroup = gWorld.newGroup("TrackGroup")
- havokTrackGroup = gWorld.newGroup("HavokTrackGroup")
- buildingGroup = gWorld.newGroup("BuildingGroup")
- vertList = []
- havokVertList = []
- gTargetPoints = []
- currDirection = 0
- currCenter = vector(0, 0, 0)
- add(gTargetPoints, currCenter)
- totalPieces = 0
- radDirection = currDirection / 180.0 * PI
- trackWidth = 50
- wallHeight = 8
- havokWallHeight = 20
- wallWidth = 4
- vertList = []
- havokVertList = []
- objectVertList = []
- add(vertList, vector(-cos(radDirection) * (wallWidth + trackWidth), 0, -sin(radDirection) * (wallWidth + trackWidth)) + currCenter)
- add(vertList, vector(-cos(radDirection) * (wallWidth + trackWidth), wallHeight, -sin(radDirection) * (wallWidth + trackWidth)) + currCenter)
- add(vertList, vector(-cos(radDirection) * (trackWidth + 2), wallHeight, -sin(radDirection) * (trackWidth + 2)) + currCenter)
- add(vertList, vector(-cos(radDirection) * trackWidth, 0, -sin(radDirection) * trackWidth) + currCenter)
- add(vertList, vector(cos(radDirection) * trackWidth, 0, sin(radDirection) * trackWidth) + currCenter)
- add(vertList, vector(cos(radDirection) * (trackWidth + 2), wallHeight, sin(radDirection) * (trackWidth + 2)) + currCenter)
- add(vertList, vector(cos(radDirection) * (wallWidth + trackWidth), wallHeight, sin(radDirection) * (wallWidth + trackWidth)) + currCenter)
- add(vertList, vector(cos(radDirection) * (wallWidth + trackWidth), 0, sin(radDirection) * (wallWidth + trackWidth)) + currCenter)
- add(havokVertList, vector(-cos(radDirection) * (trackWidth + 4), havokWallHeight, -sin(radDirection) * (trackWidth + 4)) + currCenter)
- add(havokVertList, vector(-cos(radDirection) * (trackWidth + 4), 0, -sin(radDirection) * (trackWidth + 4)) + currCenter)
- add(havokVertList, vector(cos(radDirection) * (trackWidth + 4), 0, sin(radDirection) * (trackWidth + 4)) + currCenter)
- add(havokVertList, vector(cos(radDirection) * (trackWidth + 4), havokWallHeight, sin(radDirection) * (trackWidth + 4)) + currCenter)
- beginningVerts = vertList.duplicate()
- beginningHavokVerts = havokVertList.duplicate()
- repeat with i = 1 to theTrack.road.count
- theType = theTrack.road[i].type
- if i = 3 then
- add(logoList, gWorld.shader("swirlbluebillboardShader"))
- add(logoList, gWorld.shader("swirlorangebillboardShader"))
- end if
- repeat with k = vertList.count - VerticesPerSeg down to 1
- deleteAt(vertList, k)
- end repeat
- repeat with k = havokVertList.count - havokVerticesPerSeg down to 1
- deleteAt(havokVertList, k)
- end repeat
- trackObjects = []
- objectVertList = []
- numFaces = FacesPerSeg * theTrack.road[i].num
- numVertices = VerticesPerSeg * (theTrack.road[i].num + 1)
- numNormals = 0
- numColors = 2
- havokNumFaces = havokFacesPerSeg * theTrack.road[i].num
- havokNumVertices = havokVerticesPerSeg * (theTrack.road[i].num + 1)
- havokNumNormals = 0
- havokNumColors = 2
- havokNumTexCoords = 0
- if (theType = #right) or (theType = #left) then
- numTexCoords = 7
- if theTrack.road[i].Degree > 40 then
- theTrack.road[i].num = theTrack.road[i].num * 2
- theTrack.road[i].Degree = theTrack.road[i].num / 2.0
- isDoubled = 1
- texCoordList = [[0.0, 0.0], [1, 0.0], [0.0, 1], [1, 1], [0.25, 0.0], [0.0, 1], [0.25, 1]]
- else
- isDoubled = 0
- texCoordList = [[0.0, 0.0], [1, 0.0], [0.0, 1], [1, 1], [0.5, 0.0], [0.0, 1], [0.5, 1]]
- end if
- else
- numTexCoords = 4
- texCoordList = [[0.0, 0.0], [1, 0.0], [0.0, 1], [1, 1]]
- end if
- nm = gWorld.newMesh("trackMesh_" & i, numFaces, numVertices, numNormals, numColors, numTexCoords)
- nm.colorList = [rgb("#FFFFFF"), rgb("#CCCC00")]
- nm.textureCoordinateList = texCoordList
- hnm = gWorld.newMesh("havokTrackMesh_" & i, havokNumFaces, havokNumVertices, havokNumNormals, havokNumColors, havokNumTexCoords)
- faceCount = 0
- havokFaceCount = 0
- repeat with j = 1 to theTrack.road[i].num
- if theTrack.objects.count < (totalPieces + 1) then
- theTrack.objects[totalPieces + 1] = 0
- end if
- if theType = #right then
- currDirection = currDirection + theTrack.road[i].Degree
- leftOffset = theTrack.road[i].Degree * 2
- rightOffset = -leftOffset
- isTurn = 1
- else
- if theType = #left then
- currDirection = currDirection - theTrack.road[i].Degree
- rightOffset = theTrack.road[i].Degree * 2
- leftOffset = -rightOffset
- isTurn = 1
- else
- rightOffset = 0
- leftOffset = 0
- isTurn = 0
- end if
- end if
- rightOffset = 0
- leftOffset = 0
- radDirection = currDirection / 180.0 * PI
- if isTurn = 1 then
- if isDoubled then
- theDist = DistPerSection / 4
- else
- theDist = DistPerSection / 2
- end if
- else
- theDist = DistPerSection
- end if
- if theType = #Connect then
- repeat with l = 1 to beginningVerts.count
- add(vertList, beginningVerts[l])
- end repeat
- repeat with l = 1 to beginningHavokVerts.count
- add(havokVertList, beginningHavokVerts[l])
- end repeat
- else
- newX = currCenter.x + (sin(radDirection) * theDist)
- newY = currCenter.y + theTrack.road[i].height
- newZ = currCenter.z - (cos(radDirection) * theDist)
- if (j = theTrack.road[i].num) and (i < theTrack.road.count) then
- oldHeight = newY - theTrack.road[i].height
- nextHeight = newY + (theTrack.road[i + 1].height / 2)
- newY = oldHeight + ((nextHeight - oldHeight) / 2)
- else
- if (j = 1) and (i > 1) and (i < theTrack.road.count) then
- newY = newY - (theTrack.road[i].height / 2)
- end if
- end if
- currCenter = vector(newX, newY, newZ)
- add(gTargetPoints, currCenter)
- add(vertList, vector(-cos(radDirection) * (wallWidth + trackWidth), 0 + leftOffset - 0.05, -sin(radDirection) * (wallWidth + trackWidth)) + currCenter)
- add(vertList, vector(-cos(radDirection) * (wallWidth + trackWidth), wallHeight + leftOffset, -sin(radDirection) * (wallWidth + trackWidth)) + currCenter)
- add(vertList, vector(-cos(radDirection) * (trackWidth + 2), wallHeight + leftOffset, -sin(radDirection) * (trackWidth + 2)) + currCenter)
- add(vertList, vector(-cos(radDirection) * trackWidth, 0 + leftOffset, -sin(radDirection) * trackWidth) + currCenter)
- add(vertList, vector(cos(radDirection) * trackWidth, 0 + rightOffset, sin(radDirection) * trackWidth) + currCenter)
- add(vertList, vector(cos(radDirection) * (trackWidth + 2), wallHeight + rightOffset, sin(radDirection) * (trackWidth + 2)) + currCenter)
- add(vertList, vector(cos(radDirection) * (wallWidth + trackWidth), wallHeight + rightOffset, sin(radDirection) * (wallWidth + trackWidth)) + currCenter)
- add(vertList, vector(cos(radDirection) * (wallWidth + trackWidth), 0 + rightOffset - 0.05, sin(radDirection) * (wallWidth + trackWidth)) + currCenter)
- add(havokVertList, vector(-cos(radDirection) * trackWidth, havokWallHeight + leftOffset, -sin(radDirection) * trackWidth) + currCenter)
- add(havokVertList, vector(-cos(radDirection) * trackWidth, 0 + leftOffset, -sin(radDirection) * trackWidth) + currCenter)
- add(havokVertList, vector(cos(radDirection) * trackWidth, 0 + rightOffset, sin(radDirection) * trackWidth) + currCenter)
- add(havokVertList, vector(cos(radDirection) * trackWidth, havokWallHeight + rightOffset, sin(radDirection) * trackWidth) + currCenter)
- end if
- if theTrack.objects[totalPieces + 1] = #Billboard then
- numTexCoords = 4
- numFaces = 6
- numNormals = 0
- numColors = 3
- numTexCoords = 4
- texCoordList = [[0.0, 0.0], [1, 0.0], [0.0, 1], [1, 1]]
- objectVertList = []
- objFaceCount = 0
- obj = gWorld.newMesh("objectMesh_" & i & "_" & j, numFaces, numVertices, numNormals, numColors, numTexCoords)
- obj.colorList = [rgb("#FFFFFF"), rgb("#FFFFFF")]
- obj.textureCoordinateList = texCoordList
- add(objectVertList, vector(-cos(radDirection) * (wallWidth + trackWidth + 1), 0 + leftOffset - 0.05, -sin(radDirection) * (wallWidth + trackWidth + 0.20000000000000001)) + currCenter)
- add(objectVertList, vector(-cos(radDirection) * (wallWidth + trackWidth + 1), 16 + leftOffset - 0.05, -sin(radDirection) * (wallWidth + trackWidth + 0.20000000000000001)) + currCenter)
- add(objectVertList, vector(-cos(radDirection) * (wallWidth + trackWidth + 1), 30 + leftOffset - 0.05, -sin(radDirection) * (wallWidth + trackWidth + 0.20000000000000001)) + currCenter)
- add(objectVertList, vector(-cos(radDirection) * (wallWidth + trackWidth), 0 + leftOffset - 0.05, -sin(radDirection) * (wallWidth + trackWidth)) + currCenter)
- add(objectVertList, vector(-cos(radDirection) * (wallWidth + trackWidth), 16 + leftOffset - 0.05, -sin(radDirection) * (wallWidth + trackWidth)) + currCenter)
- add(objectVertList, vector(cos(radDirection) * (wallWidth + trackWidth + 1), 0 + leftOffset - 0.05, sin(radDirection) * (wallWidth + trackWidth + 0.20000000000000001)) + currCenter)
- add(objectVertList, vector(cos(radDirection) * (wallWidth + trackWidth + 1), 16 + leftOffset - 0.05, sin(radDirection) * (wallWidth + trackWidth + 0.20000000000000001)) + currCenter)
- add(objectVertList, vector(cos(radDirection) * (wallWidth + trackWidth + 1), 30 + leftOffset - 0.05, sin(radDirection) * (wallWidth + trackWidth + 0.20000000000000001)) + currCenter)
- add(objectVertList, vector(cos(radDirection) * (wallWidth + trackWidth), 0 + leftOffset - 0.05, sin(radDirection) * (wallWidth + trackWidth)) + currCenter)
- add(objectVertList, vector(cos(radDirection) * (wallWidth + trackWidth), 16 + leftOffset - 0.05, sin(radDirection) * (wallWidth + trackWidth)) + currCenter)
- objFaceCount = objFaceCount + 1
- currNum = (trackObjects.count * 10) + 1
- obj.face[objFaceCount].vertices = [currNum, currNum + 3, currNum + 1]
- obj.face[objFaceCount].colors = [2, 2, 2]
- objFaceCount = objFaceCount + 1
- obj.face[objFaceCount].vertices = [currNum + 3, currNum + 4, currNum + 1]
- obj.face[faceCount].colors = [2, 2, 2]
- objFaceCount = objFaceCount + 1
- obj.face[objFaceCount].vertices = [currNum + 8, currNum + 5, currNum + 9]
- obj.face[objFaceCount].colors = [2, 2, 2]
- objFaceCount = objFaceCount + 1
- obj.face[objFaceCount].vertices = [currNum + 5, currNum + 6, currNum + 9]
- obj.face[faceCount].colors = [2, 2, 2]
- objFaceCount = objFaceCount + 1
- theShader = billboardList[random(billboardList.count)]
- obj.face[objFaceCount].vertices = [currNum + 2, currNum + 1, currNum + 6]
- obj.face[objFaceCount].texCoords = [3, 1, 2]
- obj.face[objFaceCount].shader = theShader
- objFaceCount = objFaceCount + 1
- obj.face[objFaceCount].vertices = [currNum + 2, currNum + 6, currNum + 7]
- obj.face[objFaceCount].texCoords = [3, 2, 4]
- obj.face[objFaceCount].shader = theShader
- objFaceCount = objFaceCount + 1
- obj.vertexList = objectVertList
- obj.generateNormals(#flat)
- obj.build()
- obj = gWorld.newModel("Object_" & i & "_" & j, obj)
- obj.parent = buildingGroup
- end if
- if theTrack.objects[totalPieces + 1] = #start then
- numTexCoords = 4
- numFaces = 6
- numNormals = 0
- numColors = 3
- numTexCoords = 4
- texCoordList = [[0.0, 0.0], [1, 0.0], [0.0, 1], [1, 1]]
- objectVertList = []
- objFaceCount = 0
- obj = gWorld.newMesh("objectMesh_" & i & "_" & j, numFaces, numVertices, numNormals, numColors, numTexCoords)
- obj.colorList = [rgb("#FFFFFF"), rgb("#FFFFFF")]
- obj.textureCoordinateList = texCoordList
- add(objectVertList, vector(-(wallWidth + trackWidth + 1), 0 + leftOffset - 0.05, 0) + vector(0, 0, -155))
- add(objectVertList, vector(-(wallWidth + trackWidth + 1), 16 + leftOffset - 0.05, 0) + vector(0, 0, -155))
- add(objectVertList, vector(-(wallWidth + trackWidth + 1), 30 + leftOffset - 0.05, 0) + vector(0, 0, -155))
- add(objectVertList, vector(-(wallWidth + trackWidth), 0 + leftOffset - 0.05, 0) + vector(0, 0, -155))
- add(objectVertList, vector(-(wallWidth + trackWidth), 16 + leftOffset - 0.05, 0) + vector(0, 0, -155))
- add(objectVertList, vector(wallWidth + trackWidth + 1, 0 + leftOffset - 0.05, 0) + vector(0, 0, -155))
- add(objectVertList, vector(wallWidth + trackWidth + 1, 16 + leftOffset - 0.05, 0) + vector(0, 0, -155))
- add(objectVertList, vector(wallWidth + trackWidth + 1, 30 + leftOffset - 0.05, 0) + vector(0, 0, -155))
- add(objectVertList, vector(wallWidth + trackWidth, 0 + leftOffset - 0.05, 0) + vector(0, 0, -155))
- add(objectVertList, vector(wallWidth + trackWidth, 16 + leftOffset - 0.05, 0) + vector(0, 0, -155))
- objFaceCount = objFaceCount + 1
- currNum = (trackObjects.count * 10) + 1
- obj.face[objFaceCount].vertices = [currNum, currNum + 3, currNum + 1]
- obj.face[objFaceCount].colors = [2, 2, 2]
- objFaceCount = objFaceCount + 1
- obj.face[objFaceCount].vertices = [currNum + 3, currNum + 4, currNum + 1]
- obj.face[faceCount].colors = [2, 2, 2]
- objFaceCount = objFaceCount + 1
- obj.face[objFaceCount].vertices = [currNum + 8, currNum + 5, currNum + 9]
- obj.face[objFaceCount].colors = [2, 2, 2]
- objFaceCount = objFaceCount + 1
- obj.face[objFaceCount].vertices = [currNum + 5, currNum + 6, currNum + 9]
- obj.face[faceCount].colors = [2, 2, 2]
- objFaceCount = objFaceCount + 1
- theShader = startShader
- obj.face[objFaceCount].vertices = [currNum + 2, currNum + 1, currNum + 6]
- obj.face[objFaceCount].texCoords = [3, 1, 2]
- obj.face[objFaceCount].shader = theShader
- objFaceCount = objFaceCount + 1
- obj.face[objFaceCount].vertices = [currNum + 2, currNum + 6, currNum + 7]
- obj.face[objFaceCount].texCoords = [3, 2, 4]
- obj.face[objFaceCount].shader = theShader
- objFaceCount = objFaceCount + 1
- obj.vertexList = objectVertList
- obj.generateNormals(#flat)
- obj.build()
- obj = gWorld.newModel("Object_" & i & "_" & j, obj)
- obj.parent = buildingGroup
- end if
- if theTrack.objects[totalPieces + 1] = #Building then
- if random(2) = 1 then
- tempBuilding = buildingModel.clone("Building_" & totalPieces)
- else
- tempBuilding = buildingModel2.clone("Building_" & totalPieces)
- end if
- leftRightAmount = random(50) + 250
- if random(2) = 1 then
- tempBuilding.transform.position = vector(-cos(radDirection) * leftRightAmount, -960, -sin(radDirection) * leftRightAmount) + currCenter
- else
- tempBuilding.transform.position = vector(cos(radDirection) * leftRightAmount, -960, sin(radDirection) * leftRightAmount) + currCenter
- end if
- tempBuilding.transform.scale = vector(random(30) + 5, random(30) + 5, random(20) + 50)
- tempBuilding.transform.rotation = vector(-90, random(-45, 45), 0)
- tempBuilding.parent = buildingGroup
- end if
- if theTrack.objects[totalPieces + 1] = #Powerup then
- if voidp(gWorld.modelResource("PowerupObject")) then
- tp = gWorld.newModelResource("PowerupObject", #plane)
- tp.length = 6
- tp.width = 20
- else
- tp = gWorld.modelResource("PowerupObject")
- end if
- Powerup = gWorld.newModel("Powerup_" & i & "_" & j, tp)
- leftRightOffset = random(-20, 20)
- Powerup.transform.position = vector(-cos(radDirection) * leftRightOffset, 6, -sin(radDirection) * leftRightOffset) + currCenter
- Powerup.shaderList = powerupShader
- if voidp(gWorld.modelResource("PowerupSparksResource")) then
- ts = gWorld.newModelResource("PowerupSparksResource", #particle)
- ts.sizeRange.start = 0.29999999999999999
- ts.sizeRange.end = 0.80000000000000004
- ts.lifeTime = 3000
- ts.emitter.minSpeed = 8
- ts.emitter.maxSpeed = 15
- ts.colorRange.end = rgb("FF9900")
- ts.colorRange.start = rgb("FFFF00")
- ts.emitter.numParticles = 200
- ts.emitter.mode = #stream
- ts.emitter.loop = 1
- ts.emitter.angle = 30
- ts.emitter.direction = vector(0, 1, 0)
- ts.emitter.path = [vector(0, 0, 0), vector(0, 30, 0)]
- ts.emitter.pathStrength = 0.001
- else
- ts = gWorld.modelResource("PowerupSparksResource")
- end if
- tm = gWorld.newModel("PowerupSparks_" & i & "_" & j, ts)
- tm.parent = Powerup
- tm.transform.position = vector(0, -8, 0)
- add(gPowerupList, Powerup)
- end if
- baseNum = ((j - 1) * VerticesPerSeg) + 1
- colorReverse = 0
- currRoadShader = (currRoadShader mod 2) + 1
- faceCount = faceCount + 1
- nm.face[faceCount].vertices = [baseNum, baseNum + 1, baseNum + 8]
- nm.face[faceCount].texCoords = [3, 4, 1]
- nm.face[faceCount].shader = wallSideShader
- faceCount = faceCount + 1
- nm.face[faceCount].vertices = [baseNum + 1, baseNum + 9, baseNum + 8]
- nm.face[faceCount].texCoords = [4, 2, 1]
- nm.face[faceCount].shader = wallSideShader
- faceCount = faceCount + 1
- nm.face[faceCount].vertices = [baseNum + 1, baseNum + 2, baseNum + 9]
- nm.face[faceCount].texCoords = [4, 3, 2]
- nm.face[faceCount].shader = wallTopShader
- faceCount = faceCount + 1
- nm.face[faceCount].vertices = [baseNum + 2, baseNum + 10, baseNum + 9]
- nm.face[faceCount].texCoords = [3, 1, 2]
- nm.face[faceCount].shader = wallTopShader
- faceCount = faceCount + 1
- shader1 = logoList[random(logoList.count)]
- shader2 = logoList[random(logoList.count)]
- nm.face[faceCount].vertices = [baseNum + 2, baseNum + 3, baseNum + 11]
- if colorReverse then
- if isTurn then
- nm.face[faceCount].texCoords = [6, 1, 5]
- else
- nm.face[faceCount].texCoords = [3, 1, 2]
- end if
- nm.face[faceCount].shader = shader1
- else
- if isTurn then
- nm.face[faceCount].texCoords = [6, 1, 5]
- else
- nm.face[faceCount].texCoords = [3, 1, 2]
- end if
- nm.face[faceCount].shader = shader1
- end if
- faceCount = faceCount + 1
- nm.face[faceCount].vertices = [baseNum + 2, baseNum + 11, baseNum + 10]
- if colorReverse then
- if isTurn then
- nm.face[faceCount].texCoords = [6, 5, 7]
- else
- nm.face[faceCount].texCoords = [3, 2, 4]
- end if
- nm.face[faceCount].shader = shader1
- else
- if isTurn then
- nm.face[faceCount].texCoords = [6, 5, 7]
- else
- nm.face[faceCount].texCoords = [3, 2, 4]
- end if
- nm.face[faceCount].shader = shader1
- end if
- faceCount = faceCount + 1
- nm.face[faceCount].vertices = [baseNum + 3, baseNum + 4, baseNum + 12]
- if colorReverse then
- nm.face[faceCount].texCoords = [1, 2, 4]
- if totalPieces = 0 then
- nm.face[faceCount].shader = finishShader
- else
- nm.face[faceCount].shader = roadShaders[currRoadShader]
- end if
- else
- nm.face[faceCount].texCoords = [1, 2, 4]
- if totalPieces = 0 then
- nm.face[faceCount].shader = finishShader
- else
- nm.face[faceCount].shader = roadShaders[currRoadShader]
- end if
- end if
- faceCount = faceCount + 1
- nm.face[faceCount].vertices = [baseNum + 3, baseNum + 12, baseNum + 11]
- if colorReverse then
- nm.face[faceCount].texCoords = [1, 4, 3]
- if totalPieces = 0 then
- nm.face[faceCount].shader = finishShader
- else
- nm.face[faceCount].shader = roadShaders[currRoadShader]
- end if
- else
- nm.face[faceCount].texCoords = [1, 4, 3]
- if totalPieces = 0 then
- nm.face[faceCount].shader = finishShader
- else
- nm.face[faceCount].shader = roadShaders[currRoadShader]
- end if
- end if
- faceCount = faceCount + 1
- nm.face[faceCount].vertices = [baseNum + 4, baseNum + 5, baseNum + 13]
- if colorReverse then
- if isTurn then
- nm.face[faceCount].texCoords = [5, 7, 6]
- else
- nm.face[faceCount].texCoords = [2, 4, 3]
- end if
- nm.face[faceCount].shader = shader2
- else
- if isTurn then
- nm.face[faceCount].texCoords = [5, 7, 6]
- else
- nm.face[faceCount].texCoords = [2, 4, 3]
- end if
- nm.face[faceCount].shader = shader2
- end if
- faceCount = faceCount + 1
- nm.face[faceCount].vertices = [baseNum + 4, baseNum + 13, baseNum + 12]
- if colorReverse then
- if isTurn then
- nm.face[faceCount].texCoords = [5, 6, 1]
- else
- nm.face[faceCount].texCoords = [2, 3, 1]
- end if
- nm.face[faceCount].shader = shader2
- else
- if isTurn then
- nm.face[faceCount].texCoords = [5, 6, 1]
- else
- nm.face[faceCount].texCoords = [2, 3, 1]
- end if
- nm.face[faceCount].shader = shader2
- end if
- faceCount = faceCount + 1
- nm.face[faceCount].vertices = [baseNum + 5, baseNum + 6, baseNum + 14]
- nm.face[faceCount].texCoords = [3, 2, 4]
- nm.face[faceCount].shader = wallTopShader
- faceCount = faceCount + 1
- nm.face[faceCount].vertices = [baseNum + 5, baseNum + 14, baseNum + 13]
- nm.face[faceCount].texCoords = [3, 4, 1]
- nm.face[faceCount].shader = wallTopShader
- faceCount = faceCount + 1
- nm.face[faceCount].vertices = [baseNum + 6, baseNum + 7, baseNum + 15]
- nm.face[faceCount].texCoords = [4, 3, 1]
- nm.face[faceCount].shader = wallSideShader
- faceCount = faceCount + 1
- nm.face[faceCount].vertices = [baseNum + 6, baseNum + 15, baseNum + 14]
- nm.face[faceCount].texCoords = [4, 1, 2]
- nm.face[faceCount].shader = wallSideShader
- faceCount = faceCount + 1
- nm.face[faceCount].vertices = [baseNum + 0, baseNum + 8, baseNum + 7]
- nm.face[faceCount].texCoords = [3, 1, 4]
- nm.face[faceCount].shader = roadBotShader
- faceCount = faceCount + 1
- nm.face[faceCount].vertices = [baseNum + 7, baseNum + 8, baseNum + 15]
- nm.face[faceCount].texCoords = [4, 1, 2]
- nm.face[faceCount].shader = roadBotShader
- baseNum = ((j - 1) * havokVerticesPerSeg) + 1
- havokFaceCount = havokFaceCount + 1
- hnm.face[havokFaceCount].vertices = [baseNum, baseNum + 1, baseNum + 4]
- havokFaceCount = havokFaceCount + 1
- hnm.face[havokFaceCount].vertices = [baseNum + 1, baseNum + 5, baseNum + 4]
- havokFaceCount = havokFaceCount + 1
- hnm.face[havokFaceCount].vertices = [baseNum + 1, baseNum + 2, baseNum + 5]
- havokFaceCount = havokFaceCount + 1
- hnm.face[havokFaceCount].vertices = [baseNum + 2, baseNum + 6, baseNum + 5]
- havokFaceCount = havokFaceCount + 1
- hnm.face[havokFaceCount].vertices = [baseNum + 2, baseNum + 3, baseNum + 6]
- havokFaceCount = havokFaceCount + 1
- hnm.face[havokFaceCount].vertices = [baseNum + 3, baseNum + 7, baseNum + 6]
- totalPieces = totalPieces + 1
- end repeat
- nm.vertexList = vertList
- nm.generateNormals(#flat)
- nm.build()
- hnm.vertexList = havokVertList
- hnm.build()
- nm = gWorld.newModel("Track_" & i, nm)
- nm.parent = trackGroup
- hnm = gWorld.newModel("HavokTrack_" & i, hnm)
- hnm.parent = havokTrackGroup
- nm.transform.position = vector(0, -7, 0)
- hnm.transform.position = vector(0, -8, 0)
- end repeat
- the randomSeed = the milliSeconds
- return
- end
-